-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Support generating change files from conventional commits #513
base: master
Are you sure you want to change the base?
Conversation
This is a nice thought - one that could potentially be expounded upon. Say, the flow could even be "at the time of a git commit, if it has a certain format, generate the change file along with the commit." This way, you're even skipping the "beachball change" step! |
more scenarios to consider:
|
@Aaron-Pool landing this on my backlog, but has kept getting pushed down. I am hoping to find some time this month. |
@asmundg How much work is still outstanding? Is it in a state that I could play around with it? Or is it not usable at all? |
@Aaron-Pool I use it daily. :) The outstanding work is mostly around cleaning up and looking at integrating into git hooks. As such, this change is self-contained, but we wanted to think some more about usage patterns before we just added it. |
@asmundg, cool, I think I'll install your PR and play around with it. Also, small tidbit of initial feedback--shouldn't |
|
||
switch (d.type) { | ||
case 'fix': | ||
case 'chore': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would chore
map to patch
here? When I think of chore
commits, I usually think of things like bumping a dev dependency or other changes that do not affect the published package.
Also, can you add support docs
and test
as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tido64 I've been doing some hacking locally to get it "just right" and I think what would be best would be to let the user provide a dictionary of allowed types and the change type (major/minor/patch/none) it should map to. That has worked well for me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that makes sense. Also, I just saw your comment now, asking the exact same question 🤣
|
||
function map(d: ConventionalCommit): Change | undefined { | ||
if (d.breaking) { | ||
return { type: 'major', message: d.message }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a special case here, for semver 0.x.y packages. In that scheme breaking changes are a minor bump, and fixes/feats are a patch bump.
npm, dependabot, are aware of that scheme, it it's used in some common packages like react-native.
case 'fix': | ||
return { type: 'patch', message: d.message }; | ||
case 'feat': | ||
return { type: 'minor', message: d.message }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does this intersect with prerelease packages?
} | ||
|
||
export function parseConventionalCommit(commitMessage: string): Change | undefined { | ||
const match = commitMessage.match(COMMIT_RE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: consider doing case insensitive match
83c6dae
to
0de404a
Compare
This adds optional support for parsing changefile properties from structured conventional commit messages. When --useConventionalCommits is set, and at least one commit message from the current branch adheres to the structured commits standard, the last conforming commit message is used to populate the change files' type and description.